package com.abaaba.project2.controller;

import com.abaaba.project2.bean.bo.AdTopicReqBo;
import com.abaaba.project2.bean.bo.AddAdvertisementTopicBo;
import com.abaaba.project2.bean.bo.UpdateAdvertisementTopicBo;
import com.abaaba.project2.bean.data.AdvertisementTopicInfo;
import com.abaaba.project2.bean.vo.AddAdvertisementTopicVo;
import com.abaaba.project2.bean.vo.AdvertisementTopicListVo;
import com.abaaba.project2.bean.vo.BaseRespVo;
import com.abaaba.project2.service.AdvertisementService;
import com.abaaba.project2.service.AdvertisementTopicService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/admin/topic")
public class AdvertisementTopicController {

    @Autowired
    AdvertisementTopicService advertisementTopicService;

    /**
     * 显示广告专题列表/按条件查询专题
     * @param baseReqBo
     * @return
     */
    @RequestMapping("/list")
    public BaseRespVo list(AdTopicReqBo baseReqBo){

        AdvertisementTopicListVo advertisementTopicListVo =  advertisementTopicService.queryTopic(baseReqBo);

        return BaseRespVo.ok(advertisementTopicListVo);
    }

    /**
     * 添加广告专题
     * @param addAdvertisementTopicBo
     * @return
     */
    @RequestMapping("/create")
    public BaseRespVo create(@RequestBody AddAdvertisementTopicBo addAdvertisementTopicBo){

       AddAdvertisementTopicVo addAdvertisementTopicVo = advertisementTopicService.createAdTopic(addAdvertisementTopicBo);

        return BaseRespVo.ok(addAdvertisementTopicVo);
    }

    /**
     * 更新广告专题
     * @param updateAdvertisementTopicBo
     * @return
     */
    @RequestMapping("/update")
    public BaseRespVo update(@RequestBody UpdateAdvertisementTopicBo updateAdvertisementTopicBo ){
        AdvertisementTopicInfo addAdvertisementTopicVo = advertisementTopicService.updateAdTopic(updateAdvertisementTopicBo);

        return BaseRespVo.ok(addAdvertisementTopicVo);
    }

    @RequestMapping("/delete")
    public BaseRespVo delete(@RequestBody AdvertisementTopicInfo advertisementTopicInfo){
        advertisementTopicService.deleteAdTopic(advertisementTopicInfo);
        return BaseRespVo.ok();
    }

}
